package com.fangfang.home.views;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.AttributeSet;
import androidx.annotation.Nullable;

public class FontTextView extends androidx.appcompat.widget.AppCompatTextView {

    public FontTextView(Context context)
    {
        super(context);
        init(context);
    }

    public FontTextView(Context context, @Nullable AttributeSet attrs)
    {
        super(context, attrs);
        init(context);
    }

    public FontTextView(Context context, @Nullable AttributeSet attrs,
                                int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    /**
     * 定制字体
     */
    private void init(Context context)
    {
        // 获取资源文件
        AssetManager assets = context.getAssets();
        Typeface font =
                Typeface.createFromAsset(assets, "fonts/Lobster-1.4.otf");
        setTypeface(font);
    }
}
